import com.aliyun.odps.udf.UDF;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class vin_8 extends UDF {
    // TODO define parameters and return type, e.g:  public String evaluate(String a, String b)
    public String evaluate(String vin) {
        String result;
        String ffid;
        String vmi;
        String year;



        if (vin == "" || vin == null) {
            result = "vin为空";
        } else if(vin.length()==17){
            vin = vin.toUpperCase();
            Pattern pattern = Pattern.compile("(L[0-9ABCDEFGHJKLMNPRSTUVWXYZ]{16})");
            Matcher matcher = pattern.matcher(vin);
            if (matcher.find()) {
                ffid = matcher.group(1);
                vmi = ffid.substring(0, 8);
                year=ffid.substring(9,10);

                    result = vmi;




            } else {
                result = "国外车";
            }

        } else {
            result = "vin码错误";

        }


        return result;
    }
}